﻿using MovingChame.Web.Infrastructure;
using MovingChame.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace MovingChame.Web.Services
{
    public class ScheduleService : IScheduleService
    {
        #region Properties
        private IScheduleProvider scheduleProvider;
        private ILocationProvider locationProvider;
        private ITourProvider tourProvider;
        #endregion

        #region Constructor
        public ScheduleService()
        {
            scheduleProvider = ScheduleProvider.Current;
            locationProvider = LocationProvider.Current;
            tourProvider = TourProvider.Current;
        }
        #endregion

        #region Operation Methods
        public List<ScheduleData> GetTourSchedule(int tourId)
        {
            List<ScheduleData> result = new List<ScheduleData>();
            IQueryable<Schedule> schedules = scheduleProvider.GetScheduleByTour(tourId);
            foreach (Schedule schedule in schedules)
            {
                result.Add(DataConverter.ConvertToScheduleData(schedule));
            }
            return result;
        }
        #endregion
    }
}